package day0724API;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;

public class Test5 {
    public static void main(String[] args) {
        List<Character> list=new LinkedList<>();
        list.add('中');
        list.add('国');
        list.add('你');
        list.add('好');

        MyConsumer m=new MyConsumer(){
            public void s(Object o){
                System.out.print(o+",");
            }
        };
        list.forEach(m::s);//表示调用匿名类对象m的s方法


        Consumer c=new Consumer<Character>() {
            public void accept(Character character) {

            }
        };
        list.forEach(c);//forEach会自动调用accept方法
    }
}

class MyConsumer{
    public void s(Object o){

    }
}




